package com.gitee.wsl.mathematics.matrix.ext

import com.gitee.wsl.mathematics.matrix.mat2.Matrix2
import com.gitee.wsl.mathematics.matrix.mat2.MutableMatrix2
import com.gitee.wsl.mathematics.matrix.mat3.Matrix3
import com.gitee.wsl.mathematics.matrix.mat3.MutableMatrix3
import com.gitee.wsl.mathematics.matrix.mat4.Matrix4
import com.gitee.wsl.mathematics.matrix.mat4.MutableMatrix4


operator fun<T:Number> MutableMatrix2<T, *, *>.timesAssign(other: Matrix2<T, *, *>){
    /*
    fun f(x: Int, y: Int) = this[0, y] * other[x, 0] + this[1, y] * other[x, 1]
    update(::f)
    */
    fun f(x: Int, y: Int) = this[0, y] * other[x, 0] + this[1, y] * other[x, 1]
    update(::f)
}

operator fun<T:Number> MutableMatrix3<T, *, *>.timesAssign(other: Matrix3<T, *, *>){
    fun f(x: Int, y: Int) = this[0, y] * other[x, 0] + this[1, y] * other[x, 1] + this[2, y] * other[x, 2]
    update(::f)
}

operator fun<T:Number> MutableMatrix4<T, *, *>.timesAssign(other: Matrix4<T, *, *>){
    fun f(x:Int,y:Int) = this[0, y] * other[x, 0] + this[1, y] * other[x, 1] + this[2, y] * other[x, 2]+ this[3, y] * other[x, 3]
    update(::f)
}